]>
Commit | Line | Data |
---|---|---|
768e492e RBR |
1 | class FlatBezelCollectingSearchObjectView: QSCollectingSearchObjectView { |
2 | override static var cellClass : AnyClass? { | |
3 | get { return BBObjectCell.self } | |
4 | set { super.cellClass = newValue } | |
5 | } | |
6 | ||
7 | override func draw(_ rect: NSRect) { | |
8 | var frame = frame | |
9 | ||
10 | // These properties aren't available to Swift, so they need to be accessed in this way. | |
11 | let collection = (value(forKey: "collection") as! NSMutableArray) | |
12 | let collecting = (value(forKey: "collecting") as! Bool) | |
13 | ||
14 | let count = collection.count | |
15 | if self.currentEditor() == nil && count != 0 { | |
16 | frame.origin = NSZeroPoint | |
17 | cell?.draw(withFrame: frame, in: self) | |
18 | let iconSize = collectionSpace() != 0 ? collectionSpace() : 16 | |
19 | let opacity = collecting ? 1.0 : 0.75 | |
20 | let totalWidth = iconSize + 2 | |
21 | for i in 0..<count { | |
22 | let object = collection.object(at: i) as! QSObject | |
23 | var icon = object.icon() | |
24 | let size = NSMakeSize(16, 16) | |
25 | icon?.size = size | |
26 | let inRect = NSMakeRect( | |
27 | frame.size.width - totalWidth * CGFloat(count - i), | |
28 | frame.origin.y + 2, | |
29 | iconSize, | |
30 | iconSize | |
31 | ) | |
32 | icon?.draw(in: inRect, from: rectFromSize(size), operation: .sourceOver, fraction: opacity) | |
33 | } | |
34 | } else { | |
35 | super.draw(rect) | |
36 | } | |
37 | } | |
38 | } |